﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KPIS.GERP.GHRMS.APP.GerpAuthenService;

namespace KPIS.GERP.GHRMS.APP
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            OTP otp ;
            
            if(string.IsNullOrEmpty(Request["token"]) || 
                (otp = new GerpAuthenService.GerpAuthenService().GetOTP(Request["token"])) == null)
            {
                Response.Redirect("~/App_UI/Forms/Default.aspx");
            } else
            {
                new SsMng().SetLoginSession(
                    Convert.ToString(otp.UserId),
                    Convert.ToString(otp.EmpId),
                    otp.UserCode,
                    Convert.ToString(otp.WorkingJobSiteSeq)
                    );
                Response.Redirect(otp.RedirectUrl);
            }
        }
    }
}